﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FrameworkElementExtensions.cs" company="Marcin Jastrzebski">
//   Copyright (c) Marcin Jastrzebski (marcin@marcinj.net)
// </copyright>
// <summary>
//   The framework element extensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace mPassRT.Utilities
{
    using Windows.Foundation;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Media;

    /// <summary>The framework element extensions.</summary>
    public static class FrameworkElementExtensions
    {
        #region Public Methods and Operators

        /// <summary>Gets the framework element layout rectangle.</summary>
        /// <param name="element">The element.</param>
        /// <returns>The <see cref="Rect"/>.</returns>
        public static Rect GetFrameworkElementRectangle(this FrameworkElement element)
        {
            GeneralTransform transform = element.TransformToVisual(null);
            Point origin = transform.TransformPoint(new Point(0, 0));
            return new Rect(origin.X, origin.Y, element.ActualWidth, element.ActualHeight);
        }

        #endregion
    }
}